package ar.edu.itba.it.cg.grupo01.game.action;

import ar.edu.itba.it.cg.grupo01.vehicle.Car;
import com.jme.input.action.InputAction;
import com.jme.input.action.InputActionEvent;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;

public class DropFlagAction extends InputAction {

	public PrintStream posLog;
	private Car car;
	private int flag;

	public DropFlagAction(Car car) {

		this.car = car;

		try {
			posLog = new PrintStream(new FileOutputStream(("positionLog")));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void setCar(Car car) {
		this.car = car;
	}

	public void performAction(InputActionEvent evt) {
		if (evt.getTriggerPressed()) {
			Vector3f carPos = car.getChassis().getLocalTranslation();
			float[] angles = new float[3];
			car.getChassis().getLocalRotation().toAngles(angles);

			posLog.println("box" + flag + ".pos =" + carPos.x + "," + carPos.y
					+ "," + carPos.z);
			flag++;
		}
	}

}
